package com.irdstudio.efp.flow.enumeration;

import java.util.Arrays;
import java.util.Objects;

import com.irdstudio.basic.framework.core.util.StringUtil;

/**
 * 
 * route 路由bean  目前默认返回使用规则执行路由
 * 
 * @author Cytus_
 * @since 2018年5月24日 下午3:18:33
 * @version 1.0
 *
 */
public enum RouteTypeBean {
	
	S("defaultRouteServicePluginExecutor"),
	R("defaultRouteRuleExector"),
	E("defaultRouteExpressionExecutor"),
    D("defaultRouteDynamicDroolsExecutor");
	
	private String value;
	
	private RouteTypeBean(String value) {
		this.value = value;
	}
	
	public String getValue() {
		return value;
	}
	
	public static RouteTypeBean getPluginTypeBean(String pluginType) {
		if (StringUtil.isNotEmpty(pluginType)) {
			return Arrays.stream(RouteTypeBean.values()).filter(s -> pluginType.toUpperCase().equals(s.toString())).findFirst().orElse(null);
		}
		return D;
	}
	
	public static String getPluginTypeBeanValue(String pluginType) {
		RouteTypeBean typeBean = getPluginTypeBean(pluginType);
		if (Objects.nonNull(typeBean))
			return typeBean.getValue();
		return D.getValue();
	}

}
